package com.blb.day1thread;

public class ThreadTest3 {

    public static void main(String[] args) {
        Thread thread = new Thread(() -> {
            for(int i = 0; ;i++){
                try {
                    Thread.sleep(500);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
                System.out.println("这是守护线程---" + i);
            }
        });
        //设置守护线程
        thread.setDaemon(true);
        thread.start();
        //启动普通线程
        for(int i = 0;i < 3;i++){
            new Thread(()->{
                for(int j = 0;j < 100;j++) {
                    try {
                        Thread.sleep(100);
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    }
                    System.out.println(Thread.currentThread().getName()+"---"+j);
                }
            }).start();
        }
    }
}
